<template>
  <formItem :label="label">
    <input type="text" class="form-input" :placeholder="placeholder" :readonly="readonly" v-model="text"/>
  </formItem>
</template>
<script>
import formItem from '@/components/form-item'

export default {
  components: {
    formItem
  },
  props: {
    label: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: '请输入'
    },
    value: {
      type: [String, Number],
      default: ''
    },
    readonly: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      text: this.value
    }
  },
  watch: {
    value(newVal) {
      this.text = newVal
    },
    text(newVal) {
      this.$emit('input', newVal)
    }
  }
}
</script>
<style lang="less" scoped>
.form-input {
  width: 100%;
  display: block;
  height: 36px;
  line-height: 36px;
  border: 0;
  box-sizing: border-box;
  outline: none;
  text-align: right;
  font-size: 14px;
  color: #011445;
  -webkit-tap-highlight-color: transparent;
}
</style>